<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>classwizard.cpp 示例文件 | Qt Widgets 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-dialogs-classwizard-example.html">Class Wizard Example</a></td><td >classwizard.cpp 示例文件</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">classwizard.cpp 示例文件</h1>
<span class="subtitle">dialogs/classwizard/classwizard.cpp</span>
<!-- $$$dialogs/classwizard/classwizard.cpp-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp">

  <span class="comment">/****************************************************************************
  **
  ** Copyright (C) 2016 The Qt Company Ltd.
  ** Contact: https://www.qt.io/licensing/
  **
  ** This file is part of the examples of the Qt Toolkit.
  **
  ** $QT_BEGIN_LICENSE:BSD$
  ** Commercial License Usage
  ** Licensees holding valid commercial Qt licenses may use this file in
  ** accordance with the commercial license agreement provided with the
  ** Software or, alternatively, in accordance with the terms contained in
  ** a written agreement between you and The Qt Company. For licensing terms
  ** and conditions see https://www.qt.io/terms-conditions. For further
  ** information use the contact form at https://www.qt.io/contact-us.
  **
  ** BSD License Usage
  ** Alternatively, you may use this file under the terms of the BSD license
  ** as follows:
  **
  ** &quot;Redistribution and use in source and binary forms, with or without
  ** modification, are permitted provided that the following conditions are
  ** met:
  **   * Redistributions of source code must retain the above copyright
  **     notice, this list of conditions and the following disclaimer.
  **   * Redistributions in binary form must reproduce the above copyright
  **     notice, this list of conditions and the following disclaimer in
  **     the documentation and/or other materials provided with the
  **     distribution.
  **   * Neither the name of The Qt Company Ltd nor the names of its
  **     contributors may be used to endorse or promote products derived
  **     from this software without specific prior written permission.
  **
  **
  ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  ** &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&quot;
  **
  ** $QT_END_LICENSE$
  **
  ****************************************************************************/</span>

  <span class="preprocessor">#include &lt;QtWidgets&gt;</span>

  <span class="preprocessor">#include &quot;classwizard.h&quot;</span>

  ClassWizard<span class="operator">::</span>ClassWizard(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
      : <span class="type"><a href="qwizard.html">QWizard</a></span>(parent)
  {
      addPage(<span class="keyword">new</span> IntroPage);
      addPage(<span class="keyword">new</span> ClassInfoPage);
      addPage(<span class="keyword">new</span> CodeStylePage);
      addPage(<span class="keyword">new</span> OutputFilesPage);
      addPage(<span class="keyword">new</span> ConclusionPage);

      setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>BannerPixmap<span class="operator">,</span> <span class="type"><a href="../qtgui/qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/banner.png&quot;</span>));
      setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>BackgroundPixmap<span class="operator">,</span> <span class="type"><a href="../qtgui/qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/background.png&quot;</span>));

      setWindowTitle(tr(<span class="string">&quot;Class Wizard&quot;</span>));
  }

  <span class="type">void</span> ClassWizard<span class="operator">::</span>accept()
  {
      <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> className <span class="operator">=</span> field(<span class="string">&quot;className&quot;</span>)<span class="operator">.</span>toByteArray();
      <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> baseClass <span class="operator">=</span> field(<span class="string">&quot;baseClass&quot;</span>)<span class="operator">.</span>toByteArray();
      <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> macroName <span class="operator">=</span> field(<span class="string">&quot;macroName&quot;</span>)<span class="operator">.</span>toByteArray();
      <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> baseInclude <span class="operator">=</span> field(<span class="string">&quot;baseInclude&quot;</span>)<span class="operator">.</span>toByteArray();

      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> outputDir <span class="operator">=</span> field(<span class="string">&quot;outputDir&quot;</span>)<span class="operator">.</span>toString();
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> header <span class="operator">=</span> field(<span class="string">&quot;header&quot;</span>)<span class="operator">.</span>toString();
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> implementation <span class="operator">=</span> field(<span class="string">&quot;implementation&quot;</span>)<span class="operator">.</span>toString();

      <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> block;

      <span class="keyword">if</span> (field(<span class="string">&quot;comment&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;/*\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    &quot;</span> <span class="operator">+</span> header<span class="operator">.</span>toLatin1() <span class="operator">+</span> <span class="char">'\n'</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;*/\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;
      }
      <span class="keyword">if</span> (field(<span class="string">&quot;protect&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;#ifndef &quot;</span> <span class="operator">+</span> macroName <span class="operator">+</span> <span class="char">'\n'</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;#define &quot;</span> <span class="operator">+</span> macroName <span class="operator">+</span> <span class="char">'\n'</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;
      }
      <span class="keyword">if</span> (field(<span class="string">&quot;includeBase&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;#include &quot;</span> <span class="operator">+</span> baseInclude <span class="operator">+</span> <span class="char">'\n'</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;
      }

      block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;class &quot;</span> <span class="operator">+</span> className;
      <span class="keyword">if</span> (<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty())
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot; : public &quot;</span> <span class="operator">+</span> baseClass;
      block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;
      block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;{\n&quot;</span>;

      <span class="comment">/* qmake ignore Q_OBJECT */</span>

      <span class="keyword">if</span> (field(<span class="string">&quot;qobjectMacro&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    Q_OBJECT\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;
      }
      block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;public:\n&quot;</span>;

      <span class="keyword">if</span> (field(<span class="string">&quot;qobjectCtor&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    &quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot;(QObject *parent = 0);\n&quot;</span>;
      } <span class="keyword">else</span> <span class="keyword">if</span> (field(<span class="string">&quot;qwidgetCtor&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    &quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot;(QWidget *parent = 0);\n&quot;</span>;
      } <span class="keyword">else</span> <span class="keyword">if</span> (field(<span class="string">&quot;defaultCtor&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    &quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot;();\n&quot;</span>;
          <span class="keyword">if</span> (field(<span class="string">&quot;copyCtor&quot;</span>)<span class="operator">.</span>toBool()) {
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    &quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot;(const &quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot; &amp;other);\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    &quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot; &amp;operator=&quot;</span> <span class="operator">+</span> <span class="string">&quot;(const &quot;</span> <span class="operator">+</span> className
                       <span class="operator">+</span> <span class="string">&quot; &amp;other);\n&quot;</span>;
          }
      }
      block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;};\n&quot;</span>;

      <span class="keyword">if</span> (field(<span class="string">&quot;protect&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;#endif\n&quot;</span>;
      }

      <span class="type"><a href="../qtcore/qfile.html">QFile</a></span> headerFile(outputDir <span class="operator">+</span> <span class="char">'/'</span> <span class="operator">+</span> header);
      <span class="keyword">if</span> (<span class="operator">!</span>headerFile<span class="operator">.</span>open(<span class="type"><a href="../qtcore/qfile.html">QFile</a></span><span class="operator">::</span>WriteOnly <span class="operator">|</span> <span class="type"><a href="../qtcore/qfile.html">QFile</a></span><span class="operator">::</span>Text)) {
          <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>warning(<span class="number">0</span><span class="operator">,</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span><span class="operator">::</span>tr(<span class="string">&quot;Simple Wizard&quot;</span>)<span class="operator">,</span>
                               <span class="type"><a href="../qtcore/qobject.html">QObject</a></span><span class="operator">::</span>tr(<span class="string">&quot;Cannot write file %1:\n%2&quot;</span>)
                               <span class="operator">.</span>arg(headerFile<span class="operator">.</span>fileName())
                               <span class="operator">.</span>arg(headerFile<span class="operator">.</span>errorString()));
          <span class="keyword">return</span>;
      }
      headerFile<span class="operator">.</span>write(block);

      block<span class="operator">.</span>clear();

      <span class="keyword">if</span> (field(<span class="string">&quot;comment&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;/*\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    &quot;</span> <span class="operator">+</span> implementation<span class="operator">.</span>toLatin1() <span class="operator">+</span> <span class="char">'\n'</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;*/\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;
      }
      block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;#include \&quot;&quot;</span> <span class="operator">+</span> header<span class="operator">.</span>toLatin1() <span class="operator">+</span> <span class="string">&quot;\&quot;\n&quot;</span>;
      block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;

      <span class="keyword">if</span> (field(<span class="string">&quot;qobjectCtor&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> className <span class="operator">+</span> <span class="string">&quot;::&quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot;(QObject *parent)\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    : &quot;</span> <span class="operator">+</span> baseClass <span class="operator">+</span> <span class="string">&quot;(parent)\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;{\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;}\n&quot;</span>;
      } <span class="keyword">else</span> <span class="keyword">if</span> (field(<span class="string">&quot;qwidgetCtor&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> className <span class="operator">+</span> <span class="string">&quot;::&quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot;(QWidget *parent)\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    : &quot;</span> <span class="operator">+</span> baseClass <span class="operator">+</span> <span class="string">&quot;(parent)\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;{\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;}\n&quot;</span>;
      } <span class="keyword">else</span> <span class="keyword">if</span> (field(<span class="string">&quot;defaultCtor&quot;</span>)<span class="operator">.</span>toBool()) {
          block <span class="operator">+</span><span class="operator">=</span> className <span class="operator">+</span> <span class="string">&quot;::&quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot;()\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;{\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    // missing code\n&quot;</span>;
          block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;}\n&quot;</span>;

          <span class="keyword">if</span> (field(<span class="string">&quot;copyCtor&quot;</span>)<span class="operator">.</span>toBool()) {
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> className <span class="operator">+</span> <span class="string">&quot;::&quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot;(const &quot;</span> <span class="operator">+</span> className
                       <span class="operator">+</span> <span class="string">&quot; &amp;other)\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;{\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    *this = other;\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;}\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="char">'\n'</span>;
              block <span class="operator">+</span><span class="operator">=</span> className <span class="operator">+</span> <span class="string">&quot; &amp;&quot;</span> <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot;::operator=(const &quot;</span>
                       <span class="operator">+</span> className <span class="operator">+</span> <span class="string">&quot; &amp;other)\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;{\n&quot;</span>;
              <span class="keyword">if</span> (<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty())
                  block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    &quot;</span> <span class="operator">+</span> baseClass <span class="operator">+</span> <span class="string">&quot;::operator=(other);\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    // missing code\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;    return *this;\n&quot;</span>;
              block <span class="operator">+</span><span class="operator">=</span> <span class="string">&quot;}\n&quot;</span>;
          }
      }

      <span class="type"><a href="../qtcore/qfile.html">QFile</a></span> implementationFile(outputDir <span class="operator">+</span> <span class="char">'/'</span> <span class="operator">+</span> implementation);
      <span class="keyword">if</span> (<span class="operator">!</span>implementationFile<span class="operator">.</span>open(<span class="type"><a href="../qtcore/qfile.html">QFile</a></span><span class="operator">::</span>WriteOnly <span class="operator">|</span> <span class="type"><a href="../qtcore/qfile.html">QFile</a></span><span class="operator">::</span>Text)) {
          <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>warning(<span class="number">0</span><span class="operator">,</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span><span class="operator">::</span>tr(<span class="string">&quot;Simple Wizard&quot;</span>)<span class="operator">,</span>
                               <span class="type"><a href="../qtcore/qobject.html">QObject</a></span><span class="operator">::</span>tr(<span class="string">&quot;Cannot write file %1:\n%2&quot;</span>)
                               <span class="operator">.</span>arg(implementationFile<span class="operator">.</span>fileName())
                               <span class="operator">.</span>arg(implementationFile<span class="operator">.</span>errorString()));
          <span class="keyword">return</span>;
      }
      implementationFile<span class="operator">.</span>write(block);

      <span class="type"><a href="qdialog.html">QDialog</a></span><span class="operator">::</span>accept();
  }

  IntroPage<span class="operator">::</span>IntroPage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
      : <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>(parent)
  {
      setTitle(tr(<span class="string">&quot;Introduction&quot;</span>));
      setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>WatermarkPixmap<span class="operator">,</span> <span class="type"><a href="../qtgui/qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/watermark1.png&quot;</span>));

      label <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;This wizard will generate a skeleton C++ class &quot;</span>
                            <span class="string">&quot;definition, including a few functions. You simply &quot;</span>
                            <span class="string">&quot;need to specify the class name and set a few &quot;</span>
                            <span class="string">&quot;options to produce a header file and an &quot;</span>
                            <span class="string">&quot;implementation file for your new C++ class.&quot;</span>));
      label<span class="operator">-</span><span class="operator">&gt;</span>setWordWrap(<span class="keyword">true</span>);

      <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(label);
      setLayout(layout);
  }

  ClassInfoPage<span class="operator">::</span>ClassInfoPage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
      : <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>(parent)
  {
      setTitle(tr(<span class="string">&quot;Class Information&quot;</span>));
      setSubTitle(tr(<span class="string">&quot;Specify basic information about the class for which you &quot;</span>
                     <span class="string">&quot;want to generate skeleton source code files.&quot;</span>));
      setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>LogoPixmap<span class="operator">,</span> <span class="type"><a href="../qtgui/qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/logo1.png&quot;</span>));

      classNameLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;&amp;Class name:&quot;</span>));
      classNameLineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>;
      classNameLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(classNameLineEdit);

      baseClassLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;B&amp;ase class:&quot;</span>));
      baseClassLineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>;
      baseClassLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(baseClassLineEdit);

      qobjectMacroCheckBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;Generate Q_OBJECT &amp;macro&quot;</span>));

      groupBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>(tr(<span class="string">&quot;C&amp;onstructor&quot;</span>));

      qobjectCtorRadioButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qradiobutton.html">QRadioButton</a></span>(tr(<span class="string">&quot;&amp;QObject-style constructor&quot;</span>));
      qwidgetCtorRadioButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qradiobutton.html">QRadioButton</a></span>(tr(<span class="string">&quot;Q&amp;Widget-style constructor&quot;</span>));
      defaultCtorRadioButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qradiobutton.html">QRadioButton</a></span>(tr(<span class="string">&quot;&amp;Default constructor&quot;</span>));
      copyCtorCheckBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;&amp;Generate copy constructor and &quot;</span>
                                          <span class="string">&quot;operator=&quot;</span>));

      defaultCtorRadioButton<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);

      connect(defaultCtorRadioButton<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>toggled<span class="operator">,</span>
              copyCtorCheckBox<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qwidget.html">QWidget</a></span><span class="operator">::</span>setEnabled);

      registerField(<span class="string">&quot;className*&quot;</span><span class="operator">,</span> classNameLineEdit);
      registerField(<span class="string">&quot;baseClass&quot;</span><span class="operator">,</span> baseClassLineEdit);
      registerField(<span class="string">&quot;qobjectMacro&quot;</span><span class="operator">,</span> qobjectMacroCheckBox);
      registerField(<span class="string">&quot;qobjectCtor&quot;</span><span class="operator">,</span> qobjectCtorRadioButton);
      registerField(<span class="string">&quot;qwidgetCtor&quot;</span><span class="operator">,</span> qwidgetCtorRadioButton);
      registerField(<span class="string">&quot;defaultCtor&quot;</span><span class="operator">,</span> defaultCtorRadioButton);
      registerField(<span class="string">&quot;copyCtor&quot;</span><span class="operator">,</span> copyCtorCheckBox);

      <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>groupBoxLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
      groupBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(qobjectCtorRadioButton);
      groupBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(qwidgetCtorRadioButton);
      groupBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(defaultCtorRadioButton);
      groupBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(copyCtorCheckBox);
      groupBox<span class="operator">-</span><span class="operator">&gt;</span>setLayout(groupBoxLayout);

      <span class="type"><a href="qgridlayout.html">QGridLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>;
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(classNameLabel<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(classNameLineEdit<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(baseClassLabel<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(baseClassLineEdit<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(qobjectMacroCheckBox<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">2</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(groupBox<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">2</span>);
      setLayout(layout);
  }

  CodeStylePage<span class="operator">::</span>CodeStylePage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
      : <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>(parent)
  {
      setTitle(tr(<span class="string">&quot;Code Style Options&quot;</span>));
      setSubTitle(tr(<span class="string">&quot;Choose the formatting of the generated code.&quot;</span>));
      setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>LogoPixmap<span class="operator">,</span> <span class="type"><a href="../qtgui/qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/logo2.png&quot;</span>));

      commentCheckBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;&amp;Start generated files with a &quot;</span>
                                         <span class="string">&quot;comment&quot;</span>));
      commentCheckBox<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);

      protectCheckBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;&amp;Protect header file against multiple &quot;</span>
                                         <span class="string">&quot;inclusions&quot;</span>));
      protectCheckBox<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);

      macroNameLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;&amp;Macro name:&quot;</span>));
      macroNameLineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>;
      macroNameLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(macroNameLineEdit);

      includeBaseCheckBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>(tr(<span class="string">&quot;&amp;Include base class definition&quot;</span>));
      baseIncludeLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Base class include:&quot;</span>));
      baseIncludeLineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>;
      baseIncludeLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(baseIncludeLineEdit);

      connect(protectCheckBox<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>toggled<span class="operator">,</span>
              macroNameLabel<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qwidget.html">QWidget</a></span><span class="operator">::</span>setEnabled);
      connect(protectCheckBox<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>toggled<span class="operator">,</span>
              macroNameLineEdit<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qwidget.html">QWidget</a></span><span class="operator">::</span>setEnabled);
      connect(includeBaseCheckBox<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>toggled<span class="operator">,</span>
              baseIncludeLabel<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qwidget.html">QWidget</a></span><span class="operator">::</span>setEnabled);
      connect(includeBaseCheckBox<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span><span class="operator">::</span>toggled<span class="operator">,</span>
              baseIncludeLineEdit<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qwidget.html">QWidget</a></span><span class="operator">::</span>setEnabled);

      registerField(<span class="string">&quot;comment&quot;</span><span class="operator">,</span> commentCheckBox);
      registerField(<span class="string">&quot;protect&quot;</span><span class="operator">,</span> protectCheckBox);
      registerField(<span class="string">&quot;macroName&quot;</span><span class="operator">,</span> macroNameLineEdit);
      registerField(<span class="string">&quot;includeBase&quot;</span><span class="operator">,</span> includeBaseCheckBox);
      registerField(<span class="string">&quot;baseInclude&quot;</span><span class="operator">,</span> baseIncludeLineEdit);

      <span class="type"><a href="qgridlayout.html">QGridLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>;
      layout<span class="operator">-</span><span class="operator">&gt;</span>setColumnMinimumWidth(<span class="number">0</span><span class="operator">,</span> <span class="number">20</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(commentCheckBox<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">3</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(protectCheckBox<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">3</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(macroNameLabel<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(macroNameLineEdit<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">2</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(includeBaseCheckBox<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">3</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(baseIncludeLabel<span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(baseIncludeLineEdit<span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="number">2</span>);
      setLayout(layout);
  }

  <span class="type">void</span> CodeStylePage<span class="operator">::</span>initializePage()
  {
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> className <span class="operator">=</span> field(<span class="string">&quot;className&quot;</span>)<span class="operator">.</span>toString();
      macroNameLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText(className<span class="operator">.</span>toUpper() <span class="operator">+</span> <span class="string">&quot;_H&quot;</span>);

      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> baseClass <span class="operator">=</span> field(<span class="string">&quot;baseClass&quot;</span>)<span class="operator">.</span>toString();

      includeBaseCheckBox<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty());
      includeBaseCheckBox<span class="operator">-</span><span class="operator">&gt;</span>setEnabled(<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty());
      baseIncludeLabel<span class="operator">-</span><span class="operator">&gt;</span>setEnabled(<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty());
      baseIncludeLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setEnabled(<span class="operator">!</span>baseClass<span class="operator">.</span>isEmpty());

      <span class="type"><a href="../qtcore/qregularexpression.html">QRegularExpression</a></span> rx(<span class="string">&quot;Q[A-Z].*&quot;</span>);
      <span class="keyword">if</span> (baseClass<span class="operator">.</span>isEmpty()) {
          baseIncludeLineEdit<span class="operator">-</span><span class="operator">&gt;</span>clear();
      } <span class="keyword">else</span> <span class="keyword">if</span> (rx<span class="operator">.</span>match(baseClass)<span class="operator">.</span>hasMatch()) {
          baseIncludeLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText(<span class="char">'&lt;'</span> <span class="operator">+</span> baseClass <span class="operator">+</span> <span class="char">'&gt;'</span>);
      } <span class="keyword">else</span> {
          baseIncludeLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText(<span class="char">'&quot;'</span> <span class="operator">+</span> baseClass<span class="operator">.</span>toLower() <span class="operator">+</span> <span class="string">&quot;.h\&quot;&quot;</span>);
      }
  }

  OutputFilesPage<span class="operator">::</span>OutputFilesPage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
      : <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>(parent)
  {
      setTitle(tr(<span class="string">&quot;Output Files&quot;</span>));
      setSubTitle(tr(<span class="string">&quot;Specify where you want the wizard to put the generated &quot;</span>
                     <span class="string">&quot;skeleton code.&quot;</span>));
      setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>LogoPixmap<span class="operator">,</span> <span class="type"><a href="../qtgui/qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/logo3.png&quot;</span>));

      outputDirLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;&amp;Output directory:&quot;</span>));
      outputDirLineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>;
      outputDirLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(outputDirLineEdit);

      headerLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;&amp;Header file name:&quot;</span>));
      headerLineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>;
      headerLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(headerLineEdit);

      implementationLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;&amp;Implementation file name:&quot;</span>));
      implementationLineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>;
      implementationLabel<span class="operator">-</span><span class="operator">&gt;</span>setBuddy(implementationLineEdit);

      registerField(<span class="string">&quot;outputDir*&quot;</span><span class="operator">,</span> outputDirLineEdit);
      registerField(<span class="string">&quot;header*&quot;</span><span class="operator">,</span> headerLineEdit);
      registerField(<span class="string">&quot;implementation*&quot;</span><span class="operator">,</span> implementationLineEdit);

      <span class="type"><a href="qgridlayout.html">QGridLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgridlayout.html">QGridLayout</a></span>;
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(outputDirLabel<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(outputDirLineEdit<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(headerLabel<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(headerLineEdit<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(implementationLabel<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">0</span>);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(implementationLineEdit<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">1</span>);
      setLayout(layout);
  }

  <span class="type">void</span> OutputFilesPage<span class="operator">::</span>initializePage()
  {
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> className <span class="operator">=</span> field(<span class="string">&quot;className&quot;</span>)<span class="operator">.</span>toString();
      headerLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText(className<span class="operator">.</span>toLower() <span class="operator">+</span> <span class="string">&quot;.h&quot;</span>);
      implementationLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText(className<span class="operator">.</span>toLower() <span class="operator">+</span> <span class="string">&quot;.cpp&quot;</span>);
      outputDirLineEdit<span class="operator">-</span><span class="operator">&gt;</span>setText(<span class="type"><a href="../qtcore/qdir.html">QDir</a></span><span class="operator">::</span>toNativeSeparators(<span class="type"><a href="../qtcore/qdir.html">QDir</a></span><span class="operator">::</span>tempPath()));
  }

  ConclusionPage<span class="operator">::</span>ConclusionPage(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent)
      : <span class="type"><a href="qwizardpage.html">QWizardPage</a></span>(parent)
  {
      setTitle(tr(<span class="string">&quot;Conclusion&quot;</span>));
      setPixmap(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>WatermarkPixmap<span class="operator">,</span> <span class="type"><a href="../qtgui/qpixmap.html">QPixmap</a></span>(<span class="string">&quot;:/images/watermark2.png&quot;</span>));

      label <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      label<span class="operator">-</span><span class="operator">&gt;</span>setWordWrap(<span class="keyword">true</span>);

      <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(label);
      setLayout(layout);
  }

  <span class="type">void</span> ConclusionPage<span class="operator">::</span>initializePage()
  {
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> finishText <span class="operator">=</span> wizard()<span class="operator">-</span><span class="operator">&gt;</span>buttonText(<span class="type"><a href="qwizard.html">QWizard</a></span><span class="operator">::</span>FinishButton);
      finishText<span class="operator">.</span>remove(<span class="char">'&amp;'</span>);
      label<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Click %1 to generate the class skeleton.&quot;</span>)
                     <span class="operator">.</span>arg(finishText));
  }

</pre>
</div>
<!-- @@@dialogs/classwizard/classwizard.cpp -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
